/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.isi.pegasus.planner.subworkflow.partitioner;

import edu.isi.pegasus.planner.classes.ADag;
import edu.isi.pegasus.planner.dax.ADAG;
import edu.isi.pegasus.planner.namespace.Pegasus;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author wchen
 *
 **/

  class writeToFile implements Runnable
{
     private ADAG dax;
     Thread runner;
     private boolean done;
     private String daxPath;
     public void getDone()
     {
         while(!done){
             try
             {
                Thread.sleep(10000);
             }
             catch (Exception e)
             {
                 e.printStackTrace();
             }

         }
     }
     public writeToFile(ADAG dax, String daxPath)
     {
        runner = new  Thread(this, "");
        this.dax = dax;
        this.daxPath = daxPath;
        this.done   = false;
        runner.start();
     }
    public void run()
    {
        dax.writeToFile(daxPath);
        this.done = true;
    }
}

   class translateThread implements Runnable
{
     private ADag subDag;
     Thread runner;
     private boolean done;
     private Map mID2LogicalID;
     private Map mIDorLogicalID2Job;
     private Map mJob2Time;
     private int start;
     private int end;
     public void getDone()
     {
         while(!done){
             try
             {
                Thread.currentThread().sleep(1000);
             }
             catch (Exception e)
             {
                 e.printStackTrace();
             }

         }
     }
     public translateThread(ADag subDag, int start, int end,
             Map mID2LogicalID, Map mIDorLogicalID2Job, Map mJob2Time)
     {

            this.start    = start;
            this.end      = end;
            runner        = new  Thread(this, "");
            this.subDag   = subDag;
            this.done     = false;
            this.mID2LogicalID = mID2LogicalID;
            this.mIDorLogicalID2Job = mIDorLogicalID2Job;
            runner.start();
     }
    public void run()
    {
        for(int i = start ; i< end; i++ )
        {
            edu.isi.pegasus.planner.classes.Job job =
                    (edu.isi.pegasus.planner.classes.Job)subDag.vJobSubInfos.get(i);
            mID2LogicalID.put(job.jobID, job.logicalId);
            mIDorLogicalID2Job.put(job.logicalId, job);
            mIDorLogicalID2Job.put(job.jobID, job);
                         String str = (String)job.vdsNS.get(Pegasus.RUNTIME_KEY);
            if(str==null)str = "0.0";
            double runtime = Double.parseDouble(str);
            mJob2Time.put(job.jobID, runtime);

        }
        this.done = true;
    }
}



 

public class ParallelThread{
    public static void main(String[] args)
    {
        Map map = new HashMap<String, Double>();
        map.put("A", 1.1);
        map.put("B", 2.2);
        //getSizeMapThread thread1 = new getSizeMapThread(0,2,map,"");
        //thread1.runner.start();
        //double sum  = thread1.getSum();
        try{
            Thread.currentThread().sleep(1000);
        }catch (Exception e)
        {

        }
        //System.out.println(sum);
    }

}